﻿<%@ Page Language="C#" Title="All tests" AutoEventWireup="true" MasterPageFile="~/Site.Master" CodeBehind="Tests.aspx.cs" Inherits="JustTest.Tests" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <header>
        <h1><%: Title %></h1>
        <p class="lead">All active tests shown by category</p>
    </header>

    <div class="row-fluid">
        <div class="span12">

            <asp:Label Text="Select category: " AssociatedControlID="DropDownCategories" runat="server" />
            <asp:DropDownList ID="DropDownCategories" runat="server"
                SelectMethod="DropDownCategories_GetData"
                OnSelectedIndexChanged="DropDownCategories_SelectedIndexChanged" 
                AutoPostBack="true" 
                DataTextField="Name"
                DataValueField="Id">
            </asp:DropDownList>

            <asp:UpdatePanel ID="UpdatePanelTests" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:GridView ID="GridViewTests" runat="server" 
                        ItemType="JustTest.Models.Test"
                        AutoGenerateColumns="false"
                        SelectMethod="ListViewTests_GetData"
                        AllowSorting="true" 
                        OnPageIndexChanging="ListViewTests_PageIndexChanging"
                        AllowPaging="true" 
                        PageSize="10"
                        CssClass="table table-hover table-striped">
                        <Columns>
                            <asp:DynamicField DataField="Title" HeaderText="Title"/>
                            <asp:DynamicField DataField="ReleaseDate" HeaderText="ReleaseDate"/>
                            <asp:TemplateField HeaderText="Author" SortExpression="Author">
                                <ItemTemplate>
                                    <asp:HyperLink CssClass="btn btn-info" Text="<%#: Item.User.UserName %>" 
                                        NavigateUrl='<%#: "Profile.aspx?username=" + Item.User.UserName %>'
                                        runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:HyperLinkField DataNavigateUrlFormatString="Test?id={0}" 
                                ControlStyle-CssClass="btn btn-success" 
                                DataNavigateUrlFields="Id" 
                                HeaderText="Action"
                                Text="Solve" />
                        </Columns>
                        <EmptyDataTemplate>
                            <div>No tests in category <%--<%#: this.DropDownCategories.SelectedItem.Text %>--%> .</div>
                        </EmptyDataTemplate>
                    </asp:GridView>
                </ContentTemplate>
            </asp:UpdatePanel>

            <asp:UpdateProgress runat="server">
                <ProgressTemplate>
                    Loading Tests...
                </ProgressTemplate>
            </asp:UpdateProgress>
            
        </div>
    </div>

</asp:Content>
